**------------------------------------------
** Replication materials: "Elite Cues and Economic Policy Attitudes: The Mediating Role of Economic Hardship" by Charlotte Cavaille and Anja Neundorf


*** CREATING TRANSITION PROBABILITY GRAPHS ****

clear all
set more off
set scheme plottig
cd "/Users/aneundorf/Dropbox/Project_CavailleNeundorf/Paper1/Analysis"


****----------------------------------------
*** FIGURE 1: Changes in party manifestos: 1960-2011



****----------------------------------------
*** FIGURE 2: Time-varying predicted probabilities of change in economic attitudes (incl. 95% C.I.)

use "Data/transprobs_general.dta", clear 

* Time
tab time
recode time (1=1993) (2=1995) (3=1997) (4=2000) (5=2004) (6=2007)
tab time,m

*rename ideol1 ideol_1

foreach i  of any cons lib cent {

bysort ideol_1 time: egen time_ideol_`i'  = mean(`i') 
gen time_ideol_`i'_p = time_ideol_`i'*100
}

foreach i  of any cons lib cent {
bysort  ideol_1 time: egen time_ideol_`i'_se = mean(`i'_se) 
gen time_`i'_up = (time_ideol_`i' + time_ideol_`i'_se*2) * 100
gen time_`i'_low = (time_ideol_`i' - time_ideol_`i'_se*2) * 100
}


* Ideol: 1=cons, 2=lib, 3=cent

* Ideol: dealignment over time
 
twoway(rarea time_cent_up time_cent_low time if ideol_1==2, col(gs5) lc(white) fi(30)) ///
(rarea time_cent_up time_cent_low time if ideol_1==1, col(gs2) lc(gs15) fi(30)) ///
(line time_ideol_cent_p time if ideol_1==2, lw(medthick) lp(solid) lc(black)) ///
(line time_ideol_cent_p time if ideol_1==1, lw(medthick ) lp(shortdash) lc(gs6))  , ///
ytitle(Preference dealignemnt (Centrist in t, in %), size(medium)) ///
xtitle("", size(medium))  xline(1997) ///
  ylabel(0(10)35,labsize(medsmall)) ylabel(, ) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(medium)) ///
legend(order(3 4) lab(3 "Left-wing in t-1 ") lab(4 "Right-wing in t-1 ")) legend(region (lc(white)) r(2) region(lcolor(white)) pos(1) ring(0) size(medsmall)) ///
scheme(plottig) graphregion(fcolor(white)) name(deali, replace) title("A. Preference Dealignment", size(large))


* Ideol: leftist re-alignment over time
 
twoway(rarea time_lib_up time_lib_low time if ideol_1==3, col(gs5) lc(white) fi(30)) ///
(rarea time_cons_up time_cons_low time if ideol_1==3, col(gs2) lc(gs15) fi(30)) ///
(line time_ideol_lib_p time if ideol_1==3, lw(medthick) lp(solid) lc(black)) ///
(line time_ideol_cons_p time if ideol_1==3, lw(medthick ) lp(shortdash) lc(gs6))  , ///
ytitle(Prefrence realignemnt (Centrist in t-1, in %), size(medium)) ///
xtitle("", size(medium)) xline(1997) ///
  ylabel(0(10)35,labsize(medsmall)) ylabel(, ) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(medium)) ///
legend(order(3 4) lab(3 "Left-wing in t ") lab(4 "Right-wing in t")) legend(region (lc(white)) r(2) region(lcolor(white)) pos(1) ring(0) size(medsmall)) ///
scheme(plottig) graphregion(fcolor(white)) name(reali, replace) title("B. Preference Realignment", size(large))

graph combine deali reali, graphregion(fcolor(white))
graph  "Graphs/Figure2.gph", replace
graph export "Graphs/Figure2.pdf", replace



****----------------------------------------
*** FIGURE 3: LABOUR + POLITICAL INTEREST

use "Data/transprobs_polint_pid3.dta", clear 

* Time
tab time
recode time (1=1993) (2=1995) (3=1997) (4=2000) (5=2004) (6=2007)
tab time,m

** Polint+ PID
lab def pidlbl1 0"No/other PID" 1"Conservatives" 2"Labour" 3"Libdem"
lab val pid_time3 pidlbl1


*rename ideol1 ideol_1

foreach i  of any cons lib cent {

bysort ideol_1 time polint pid_time3: egen time_ideol_`i'  = mean(`i') 
gen time_ideol_`i'_p = time_ideol_`i'*100
}

foreach i  of any cons lib cent {
bysort  ideol_1 time polint pid_time3: egen time_ideol_`i'_se = mean(`i'_se) 
gen time_`i'_up = (time_ideol_`i' + time_ideol_`i'_se*2) * 100
gen time_`i'_low = (time_ideol_`i' - time_ideol_`i'_se*2) * 100
}


* Ideol: 1=lib; 2=cent; 3=cons


twoway(rarea time_cent_up time_cent_low time if ideol_1==1 & pid_time3==2 & polint==0, col(gs5) lc(white) fi(30)) ///
(rarea time_cent_up time_cent_low time if ideol_1==1 & pid_time3==2 & polint==1, col(gs2) lc(gs15) fi(30)) ///
(line time_ideol_cent_p time if ideol_1==1 & pid_time3==2 & polint==0, lw(medthick) lp(shortdash) lc(black)) ///
(line time_ideol_cent_p time if ideol_1==1 & pid_time3==2 & polint==1, lw(medthick ) lp(solid) lc(gs6))  , ///
ytitle(% of Leftist dealignemnt (Left in t-1, Centrist in t), size(medium)) ///
xtitle("") xline(1997)  ///
  ylabel(,labsize(medsmall)) ylabel(, ) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(medium)) ///
legend(order(3 4) lab(3 "Pol. interest low") lab(4 "Pol. interest high")) legend(region (lc(white)) r(2) pos(1) ring(0) size(medsmall)) name(lab, replace) ///
 graphregion(fcolor(white)) title("Labour partisans", size(large))
 
  graph save "Graphs/Figure3.gph", replace
  graph export "Graphs/Figure3.pdf", replace
  
 

****----------------------------------------
*** FIGURE 4: Left-wing Dealignment (Left-wing in t 􀀀1; Centrist in t) by material interest


**---------------------------***
**Realignment: Unemployment

use "Data/transprobs_unemp.dta", clear

* Liberal dealalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3 & ideol_1==2, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==4& ideol_1==2, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==2, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==4 & ideol_1==2, lw(medthick ) lp(solid))  , ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
 lab(3 "Lost job in t") lab(4 "Found job in t")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Objective employment change}, size(medium) ring(0)) name(`i'_deal_unemp_l, replace)  
}

* Conservative realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3 & ideol_1==1, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==4& ideol_1==1, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==3& ideol_1==1, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==4& ideol_1==1, lw(medthick ) lp(solid))  , ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
 lab(3 "Lost job in t") lab(4 "Found job in t")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Objective income change}, size(medium) ring(0)) name(`i'_deal_unemp_c, replace)  
}



**---------------------------***
**Realignment: income

use "Data/transprobs_income.dta", clear 

* Liberal realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==2, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3& ideol_1==2, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2& ideol_1==2, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==2, lw(medthick ) lp(solid))  , ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Income drop") lab(4 "Income increase")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Objective income change}, size(medium) ring(0)) name(`i'_deal_inc_l, replace)  
}
* Conservative realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==1, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3& ideol_1==1, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2 & ideol_1==1, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==1, lw(medthick ) lp(solid))  , ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Income drop") lab(4 "Income increase")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Objective employment change}, size(medium) ring(0)) name(`i'_deal_inc_c, replace)  
}
**---------------------------***
**Realignment: fin sit

use "Data/transprobs_finsit.dta", clear 

* Liberal realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==2, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3& ideol_1==2, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2& ideol_1==2, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==2, lw(medthick ) lp(solid))  , ///
ytitle(% of Leftist dealignemnt (Centrist in t), size(medium)) ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Got worse") lab(4 "Got better")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Subjective financial situation}, size(medium) ring(0)) name(`i'_deal_finsit_l, replace) 
}

foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==2, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==1& ideol_1==2, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2& ideol_1==2, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==1 & ideol_1==2, lw(medthick ) lp(solid))  , ///
ytitle(% of Liberal dealignemnt (other/centrist in t), size(medium)) ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Got worse") lab(4 "Stayed the same")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Subjective financial situation}, size(medium) ring(0)) name(`i'_deal_finsit_l2, replace) 
}


* Conservative realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==1, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3& ideol_1==1, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2 & ideol_1==1, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==1, lw(medthick ) lp(solid))  , ///
ytitle(% of Conservative dealignemnt (other/centrist in t), size(medium)) ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Got worse") lab(4 "Got better")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Subjective financial situation}, size(medium) ring(0)) name(`i'_deal_finsit_c, replace)  
}

**---------------------------***
**Realignment: job security

use "Data/transprobs_jobsec.dta", clear 

* Liberal realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==2, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3& ideol_1==2, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2& ideol_1==2, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==2, lw(medthick ) lp(solid))  , ///
ytitle(% of Leftist dealignemnt (other/centrist in t), size(medium)) ///
xtitle("", size(medium))  ///
  ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Got worse") lab(4 "Got better")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Subjective job secuirty }, size(medium) ring(0)) name(`i'_deal_jobsec_l, replace) 
}

* Conservative realalignment 
foreach i  of any cent {
twoway(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==2 & ideol_1==1, col(gs3) lc(white) fi(30)) ///
(rarea time_finsit_`i'_up time_finsit_`i'_low time if finsit_drop==3& ideol_1==1, col(gs5) lc(gs15) fi(30)) ///
(line time_finsit_`i'_p time if finsit_drop==2 & ideol_1==1, lw(medthick) lp(shortdash)) ///
(line time_finsit_`i'_p time if finsit_drop==3 & ideol_1==1, lw(medthick ) lp(solid))  , ///
xtitle("", size(medium))  ///
 ytitle(% of Conservative dealignemnt (other/centrist in t), size(medium)) ///
 ylabel(0(10)50,labsize(verysmall)) ylabel(, nogrid) xlabel(1993 1995 1997 2000 2004 2007, valuelabel labsize(small)) ///
 legend(region (lc(white))) legend(order(3 4) ///
lab(3 "Got worse") lab(4 "Got better")) ///
scheme(s2mono) graphregion(fcolor(white)) ///
title({bf:Subjective job secuirty }, size(medium) ring(0)) name(`i'_deal_jobsec_c, replace) 
 }


 graph combine cent_deal_inc_l cent_deal_unemp_l cent_deal_finsit_l cent_deal_jobsec_l, scheme(s2mono) graphregion(fcolor(white))

   graph save "Graphs/Figure4.gph", replace
  graph export "Graphs/Figure4.pdf", replace


